package com.obligatorio.domain;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;

@Entity
@NamedQueries({
	@NamedQuery(name = "findAllSector", query = "SELECT s FROM Sector s order by s.nombre"),
	@NamedQuery(name = "findSectorByName", query = "SELECT s FROM Sector s WHERE s.nombre =:Nombre") })
public class Sector implements Serializable{

	private final static long serialVersionUID = 1L;
	
	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	@Column(name="SectorID")
	private Integer id;
	
	@Column(name="SectorNombre",nullable=false)
	private String nombre;
	
	public Sector(){}
	
	public Sector(String name){
		this.nombre=name;
	}
	
	public Sector(Integer id, String nombre) {
		this.id = id;
		this.nombre = nombre;
	}

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getNombre() {
		return nombre;
	}

	public void setNombre(String nombre) {
		this.nombre = nombre;
	}
	
	@Override
    public boolean equals(Object object) {
        if (!(object instanceof Sector)) {
            return false;
        }
        Sector other = (Sector) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }
	
	@Override
    public String toString() {
        return getNombre();
    }
}
